<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.example.pojo.Role" %>
<%@ page import="com.example.pojo.Privilege" %>
<%@ page import="com.example.pojo.User" %>
<html>
	<head>
		<title>导航菜单</title>
		<%@include file="/jsp/public/header.jsp" %>
		<script language="JavaScript" src="${pageContext.request.contextPath }/script/menu.js"></script>
		<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath }/style/blue/menu.css" />
	</head>
	<body style="margin: 0">
		<div id="Menu">
		    <ul id="MenuUl">
				<li class="level1">
					<div onClick="menuClick(this)" class="level1Style"><img src="${pageContext.request.contextPath}/style/images/MenuIcon/FUNC20001.gif" class="Icon" />个人办公</div>
					<ul style="display: none;" class="MenuLevel2">
						<li class="level2">
							<div class="level2Style"><img src="${pageContext.request.contextPath}/style/images/MenuIcon/menu_arrow_single.gif" /><a target="right" href="${pageContext.request.contextPath}/attendance/show.do">个人考勤</a></div>
						</li>
						<li class="level2">
							<div class="level2Style"><img src="${pageContext.request.contextPath}/style/images/MenuIcon/menu_arrow_single.gif" /><a target="right" href="${pageContext.request.contextPath}/schedule/show.do">日程安排</a></div>
						</li>
						<li class="level2">
							<div class="level2Style"><img src="${pageContext.request.contextPath}/style/images/MenuIcon/menu_arrow_single.gif" /><a target="right" href="${pageContext.request.contextPath}/workPlan/show.do">工作计划</a></div>
						</li>
						<li class="level2">
							<div class="level2Style"><img src="${pageContext.request.contextPath}/style/images/MenuIcon/menu_arrow_single.gif" /><a target="right" href="${pageContext.request.contextPath}/diary/show.do">工作日记</a></div>
						</li>
						<li class="level2">
							<div class="level2Style"><img src="${pageContext.request.contextPath}/style/images/MenuIcon/menu_arrow_single.gif" /><a target="right" href="${pageContext.request.contextPath}/address/show.do">通讯录</a></div>
						</li>
					</ul>
				</li>
		    	<c:forEach items="${privilegeTopList}" var="p">
		    		<!-- 从Session中获取登录用户，根据用户的角色最终获取对应的权限，判断此权限是否和当前循环出的权限是否一致，如果一致就显示 -->
		    		<!-- 使用OGNL调用对象的方法 -->
<%--		    		<c:if test="${loginUser.hasPrivilegeByName(p.name)}"> 有时不行--%>
					<c:if test="${fn:contains(loginUser.privilegeIds,p.pid) || loginUser.loginName=='admin'}">
				        <li class="level1">
				            <div onclick="menuClick(this);" class="level1Style">
				            	<img src="${pageContext.request.contextPath }/style/images/MenuIcon/${p.pid }.gif" class="Icon" /> ${p.name }
				            </div>
				            <ul style="display: none;" class="MenuLevel2">
				            	<c:forEach items="${p.children}" var="p2">
								<c:if test="${fn:contains(loginUser.privilegeIds,p2.pid) || loginUser.loginName=='admin'}">
					                <li class="level2">
					                    <div class="level2Style">
					                    	<img src="${pageContext.request.contextPath }/style/images/MenuIcon/menu_arrow_single.gif" /> 
					                    	<a target="right" href="${pageContext.request.contextPath }${p2.url}">${p2.name }</a>
					                    </div>
					                </li>
					                </c:if>
				            	</c:forEach>
				            </ul>
				        </li>
		    		</c:if>
		        </c:forEach>
				<li class="level1">
					<div onClick="menuClick(this);" class="level1Style"><img src="${pageContext.request.contextPath }/style/images/MenuIcon/FUNC20077.gif" class="Icon" /> 个人设置</div>
					<ul style="display: none;" class="MenuLevel2">
						<li class="level2">
							<div class="level2Style"><img src="${pageContext.request.contextPath }/style/images/MenuIcon/menu_arrow_single.gif" /> <a target="right" href="${pageContext.request.contextPath}/user/editUserInfoUI.do">个人信息</a></div>
						</li>
						<li class="level2">
							<div class="level2Style"><img src="${pageContext.request.contextPath }/style/images/MenuIcon/menu_arrow_single.gif" /> <a target="right" href="${pageContext.request.contextPath}/user/editPasswordUI.do">密码修改</a></div>
						</li>
					</ul>
				</li>
		    </ul>
		</div>
	</body>
</html>
